/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Ashe Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2020/1/6 10:17 下午
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.capsule.spring.boot.hello.config;

import com.capsule.spring.boot.hello.annotation.EnableHelloSelector;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.MultiValueMap;

/**
 * <p>
 *
 * </p>
 *
 * @author Ashe
 * @version V1.0.0
 * @date 2020/1/6 10:17 下午
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人}  2020/1/6
 * @modify reason: {方法名}:{原因}
 * ...
 */
public class HelloConfigSelector implements ImportSelector {

    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        MultiValueMap<String, Object> metaData = importingClassMetadata.getAllAnnotationAttributes(EnableHelloSelector.class.getName());
        Boolean isMac = (Boolean) metaData.get("isMac").get(0);
        if (isMac) {
            return new String[]{HelloWorldConfig.class.getName()};
        }else{
            return new String[]{HelloWorldConfig.class.getName(),HelloFutureConfig.class.getName()};
        }
    }
}
